<html lang="en">
<head>
    <title>用户提问管理</title>
    <#include "../common/header.ftl">
    <script type="text/javascript">
        $(function () {
            //查询
            $(".clickBtn").click(function () {
                var parentId = $(this).data("parentid");
                $("#currentPage").val(1);
                $("#searchForm").submit();
            })


            //发布： 改状态
            $(".changeStateBtn").click(function () {
                var id = $(this).data("id");
                var state = $(this).data("state");
                if (state == 1){
                $.get("/question/changeState", {state:state,id:id}, function (data) {
                    if(data.success){
                        console.log(data.success);
                        window.location.reload();
                    }else{
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
                }
            })

            //高级查询
            $("#query").click(function () {
                $("#searchForm").submit();
            })

            //弹出模态框回显内容
            $(".inputBtn").click(function () {
                $("#treeview").html("");
                //数据复原
                $("#editForm").clearForm(true);
                //攻略主题回显数据
                var title = $(this).data("title");
                var content = $(this).data("content");
                var info;
                if (title){
                    info = title;
                }
                if (content){
                    info = content;
                }
                if(info){
                    $("#content").val(info);
                }
                //弹出模态框
                $("#editModal").modal("show");

            })
        })
    </script>
</head>
<body>
<!--左侧菜单回显变量设置-->
<#assign currentMenu="question">

<div class="container-fluid " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-2">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-10">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">用户提问管理</h1>
                </div>
            </div>
            <#setting number_format="#">
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/question/list" method="post">
                <input name="keyword" value="${(qo.keyword)!}"><input value="关键字查询" type="button" id="query">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
            </form>

            <table class="table table-striped table-hover" >
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>用户名</th>
                        <th>标题</th>
                        <th>目的地</th>
                        <th>状态</th>
                        <th>内容</th>
                        <th>操作</th>
                    </tr>
                </thead>
               <#list pageInfo.list as entity>
                   <tr>
                       <td>${entity_index+1}</td>
                       <td>${entity.userInfo.nickname}</td>
                       <td>
                           <a class="btn btn-info btn-xs inputBtn" href="javascript:;" data-title='${(entity.title)!}'>
                               <span class="glyphicon glyphicon-edit"></span> 查看
                           </a>
                       </td>
                       <td>${(entity.dest.name)!}</td>
                       <td>${(entity.state)!}</td>
                       <td>
                       <a class="btn btn-info btn-xs inputBtn" href="javascript:;" data-content='${(entity.content)!}'>
                           <span class="glyphicon glyphicon-edit"></span> 查看
                       </a>
                       </td>
                       <td>

                           <#if  entity.state == 1>
                            <a class="btn btn-danger btn-xs changeStateBtn" href="javascript:;" data-state='0' data-id="${entity.id}">
                                <span class="glyphicon glyphicon-minus-sign"></span> 已发布
                            </a>

                           <#else>
                            <a class="btn btn-default btn-xs changeStateBtn" href="JavaScript:;" data-state="1" data-id="${entity.id}">
                                <span class="glyphicon glyphicon-tag"></span> 发布
                            </a>
                           </#if>

                           <a href="javascript:;" class="btn btn-danger btn-xs deleteBtn"
                              data-url="/question/delete?id=${entity.id}">
                               <span class="glyphicon glyphicon-trash"></span> 删除
                           </a>
                       </td>
                   </tr>
               </#list>
            </table>
            <#--分页-->
            <#include "../common/page.ftl"/>
        </div>
    </div>
</div>

<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span> </button>
                <h4 class="modal-title">攻略主题添加/编辑</h4>
            </div>
            <div class="form-group">
                <textarea id="content" name="content" class="ckeditor"></textarea>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary submitBtn" >保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
            </div>
        </div>
    </div>
</div>


</body>
</html>